﻿using Kevin.Service.Client.Restful;
using Kevin.Shop.Business.Core.Components.Responser;
using Kevin.Shop.Business.SalesManagement.Components.Order;
using Kevin.Shop.Business.Service.Entity.Helper;
using Kevin.Shop.Business.Service.Entity.SalesManagement.Order;
using RiderShop.Mobile.Common.Component;
using RiderShop.Mobile.ServiceEntity.MyAccount;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RiderShop.Mobile.Modle.Purchase
{
    public class GreetingOrderModel
    {
        public ServiceResponser ServiceResponser { get; set; }
        public OrderBasicInfoExtend OrderInfo { get; set; }
        public OrderGreetingCardInfo OrderGreetingCardInfo { get; set; }

        /// <summary>
        /// 给好友发送送礼短信
        /// </summary>
        /// <returns></returns>
        public ServiceResponser SendGreetingOrderSMS(OrderGreetingCardInfo orderGreetingCardInfo)
        {
            ServiceResponser responser = RestfulHelper.Update<OrderGreetingCardInfo>(SiteUrl.FormatUrl("SalesManagement_SendGreetingOrderSMS"), orderGreetingCardInfo);

            return responser;
        }

        /// <summary>
        /// 确认贺卡
        /// </summary>
        /// <param name="orderGreetingCardInfo">贺卡信息</param>
        /// <returns></returns>
        public ServiceResponser ConfirmGreetingCard(OrderGreetingCardInfo orderGreetingCardInfo)
        {
            ServiceResponser responser = RestfulHelper.Update<OrderGreetingCardInfo>(SiteUrl.FormatUrl("SalesManagement_ChooseGiftCardToFriend"), orderGreetingCardInfo);

            return responser;
        }


        public void LoadOrderInfo(string orderNumber)
        {
            OrderBasicInfoExtend order = RestfulHelper.QueryWithSingle<OrderBasicInfoExtend>(SiteUrl.FormatUrl("SalesManagement_GetOrderDetailInfo", orderNumber));
            this.OrderInfo = order;
        }

        /// <summary>
        /// 得到送礼订单
        /// </summary>
        /// <param name="orderNumber">订单号</param>
        /// <returns>送礼订单信息</returns>
        public void LoadGreeting(string orderNumber)
        {
            OrderGreetingCardInfo card = RestfulHelper.QueryWithSingle<OrderGreetingCardInfo>(SiteUrl.FormatUrl("SalesManagement_GetOrderGreetingCard", orderNumber));
            this.OrderGreetingCardInfo = card;
        }

        public ServiceResponser AddGreetingAddress(OrderBasicInfo orderInfo)
        {
            ServiceResponser responser = RestfulHelper.Update<OrderBasicInfo>(SiteUrl.FormatUrl("SalesManagement_UpdateGreetingOrderShippingInfo"), orderInfo);

            return responser;
        }
    }
}
